<template>
  <div>
    <header>
      <div class="header-form">
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item>
            <el-input
              v-model="form.name"
              style="width:18rem;margin-right:1rem"
              placeholder="请输入搜索的信息"
            />
            <el-button type="primary" @click="onSubmit">查询</el-button>
          </el-form-item>
        </el-form>
      </div>

      <div class="header-bottom">
        <el-button
          type="primary"
          @click="dialogFormVisible = true"
        >新增</el-button>
        <el-button type="success">编辑</el-button>
        <el-button type="danger">删除</el-button>
      </div>
    </header>
    <main>
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="nmb" label="序号" width="180" />
        <el-table-column prop="title" label="标题" />
        <el-table-column prop="name" label="发布者" width="180" />
        <el-table-column prop="data" label="最近修改时间" width="180" />
      </el-table>
    </main>
    <el-dialog
      title="收货地址"
      width="570px"
      :visible.sync="dialogFormVisible"
    >
      <el-form :model="form" label-width="80px">
        <el-form-item
          label="标 题"
          required="true"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="form.name1"
            autocomplete="off"
            style="width:25rem"
          />
        </el-form-item>
        <el-form-item
          label="发布人"
          required="true"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="form.name2"
            autocomplete="off"
            style="width:25rem"
          />
        </el-form-item>
        <el-form-item label="正 文" required="true">
          <el-input
            v-model="form.desc"
            type="textarea"
            style="width:25rem"
            cols="40"
            rows="10"
          />
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button
          type="primary"
          @click="dialogFormVisible = false"
        >确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dialogTableVisible: false,
      dialogFormVisible: false,
      desc: '',
      form: {
        name: '',
        name1: '',
        name2: ''
      },
      tableData: [
        {
          nmb: '1',
          title: '上海市普陀区金沙江路 1518 弄',
          name: '王小虎',
          data: '2016-05-02 1518 弄'
        },
        {
          nmb: '2',
          title: '上海市普陀区金沙江路 1518 弄',
          name: '王小虎',
          data: '2016-05-02 1518 弄'
        }
      ]
    }
  },
  methods: {
    onSubmit() {
      alert('搜索成功')
    }
  }
}
</script>
<style lang="scss" scoped>
header {
  background-color: #f4f5f6;
  padding: 1rem 3rem 1rem 0;
  height: 4.5rem;
  display: flex;
  justify-content: space-between;
}
main {
  padding: 1rem 2rem 0 2rem;
}
.dialog-footer {
  width: 30rem;
}
</style>
